package ljl.alg.jianzhioffer.round2;

import commons.TreeNode;

/**
 *
 * 磨了一段时间磨出来了
 * 还是不熟反正，靠着之前的记忆磨出来了
 *
 * */
public class _28_symmetry_bitree {
    
    public boolean isSymmetric(TreeNode root) {
        if (root == null) return true;
        return alike(root.left, root.right);
    }
    boolean alike(TreeNode left, TreeNode right) {
        if (left == null || right == null) return left == right;
        return left.val == right.val
            && alike(left.left, right.right)
            && alike(left.right, right.left)
            ;
    }
}
